// my bot class for hitting the origin and through akamai

import java.io.*;
import java.util.*;
import java.net.*;

public class restak
{
    public static void main(String [] args) throws IOException
    {
        URL url;
        String urlEndpoint;
        String headerName, headerValue;
        final BufferedReader br;
        String output = "";
        final StringBuffer outputBuffer = new StringBuffer();       

        // define the API endpoint
        urlEndpoint = "http://www.thomas-bayer.com/sqlrest/CUSTOMER/3/";
        url = new URL(urlEndpoint);
                
        // open connection to API
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        
        conn.setRequestMethod("GET");
        /*
        conn.setRequestProperty("Accept", "application/xml");
        conn.addRequestProperty("Pragma", "akamai-x-get-request-id, akamai-x-cache-on, akamai-x-cache-remote-on");
        */
        
        String s = "";

        if (conn.getResponseCode() != 200)
        {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
        }

        br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        
        while ((output = br.readLine()) != null)
        {
                outputBuffer.append(output);
        }
            
        System.out.println("-----");
        System.out.println("From API: " + ((outputBuffer.toString())));
        
        System.out.println("-----");
        
        // clean up the connection
        conn.disconnect();
    
    } // end main
    
} // end class